import Cookies from "js-cookie";
import { apiUserInfo } from "@/api/login";
import store from "../store";

// 获取token
export const getCookie = (cookieName = "token") => {
  return Cookies.get(cookieName);
};

// 获取用户信息
export const getUserInfo = () => {
  if (getCookie()) {
    apiUserInfo().then((res) => {
      const userInfo = res.data;

      store.commit("set_state", { key: "userInfo", data: userInfo });
    });
  }
};
